package com.jfinal.lib.handler;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.jfinal.handler.Handler;

public class ContextPathHandler extends Handler {
	
	private String contextPathName = "CONTEXT_PATH";
	
	public ContextPathHandler() {
		
	}
	
	public ContextPathHandler(String contextPathName) {
		this.contextPathName = contextPathName;
	}
	
	public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) {
		request.setAttribute(contextPathName, request.getContextPath());
		nextHandler.handle(target, request, response, isHandled);
	}
}
